package com.gzy.rpsm_admin.pojo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel
public class ResponsePojo<T> {
    @ApiModelProperty(value = "响应的数据")
    private T data;
    @ApiModelProperty(value = "响应的信息")
    private String message;
    @ApiModelProperty(value = "响应的状态码,1:成功 2:失败")
    private int code;

    private ResponsePojo(T t){
        this.data=t;
        this.code=1;
        this.message="";
    }
    public int getCode() {
        return this.code;
    }
    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }
    public void setMessage(String message)  {
        this.message = message;
    }
    private ResponsePojo(T t,String message,int code){
        this.data=t;
        this.code=code;
        this.message=message;
    }
    public static <T> ResponsePojo<T> success(T t){
        return new ResponsePojo<T>(t);
    }
    public static <T> ResponsePojo<T> fail(T t,String message){
        return new ResponsePojo(t,message,2);
    }

}
